//
//  MXShiftInlListCell.m
//  HNBaseProject
//
//  Created by xujie on 2024/6/5.
//

#import "MXShiftInlListCell.h"

@implementation MXShiftInlListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self createUI];
    }
    return self;
}

- (void)createUI {
    self.selectionStyle = 0;
    self.backgroundColor = [UIColor colorWithHexString:@"#f5f5f5"];
    
    self.bgView = [[UIView alloc] initWithFrame:CGRectMake(15, 10, kScreenW-30, 70)];
    self.bgView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.bgView];
    self.bgView.layer.cornerRadius = 18;
    self.bgView.layer.masksToBounds = YES;
    
    self.seleImageV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"shiftin_unselect"]];
    [self.bgView addSubview:self.seleImageV];
    [self.seleImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(18);
        make.height.width.mas_equalTo(20);
        make.centerY.mas_equalTo(self.bgView);
    }];
    
    self.plaveImageV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"shiftin_place"]];
    [self.bgView addSubview:self.plaveImageV];
    [self.plaveImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(51);
        make.height.width.mas_equalTo(48);
        make.centerY.mas_equalTo(self.bgView);
    }];
    
    self.titleLab = [[UILabel alloc] init];
    self.titleLab.textColor = [UIColor dc_colorWithHexString:@"#000000" alpha:0.9];
    self.titleLab.font = PFRFontMedium(14);
    self.titleLab.text = @"智能喂食器可视版";
    [self.bgView addSubview:self.titleLab];
    [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.bgView);
        make.left.mas_equalTo(self.plaveImageV.mas_right).offset(10);
    }];
}

- (void)reloadCellWithSelect:(BOOL)select {
    self.seleImageV.image = select ? [UIImage imageNamed:@"shiftin_select"] : [UIImage imageNamed:@"shiftin_unselect"];
}
- (void)reloadCellWithModel:(MXHomeListModel *)model {
    self.titleLab.text = model.deviceLocalName;
    self.seleImageV.image = model.select ? [UIImage imageNamed:@"shiftin_select"] : [UIImage imageNamed:@"shiftin_unselect"];
}
@end
